<template>
	<section>
		<el-dialog :title="'空瓶回收价格修改'" v-model="visible" :width="'50%'" destroy-on-close @closed="$emit('closed')">
			<el-form :disabled="mode == 'Show'" ref="dialogForm" label-width="100px">
				<el-row>
					<el-col :span="5">
						<el-form-item label="单据类型：">空瓶回收</el-form-item>
					</el-col>
					<el-col :span="5">
						<el-form-item label="单据状态：">酒业待确认</el-form-item>
					</el-col>
					<el-col :span="5"></el-col>
				</el-row>
				<el-row>
					<el-col :span="5">
						<el-form-item label="申请编号：">{{entityObj.recoveryCode}}</el-form-item>
					</el-col>
					<el-col :span="5">
						<el-form-item label="申请单位：">{{entityObj.storeName}}</el-form-item>
					</el-col>
					<el-col :span="5">
						<el-form-item label="申请人：">{{entityObj.applicant}}</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="5">
						<el-form-item label="申请时间：">{{entityObj.createTime}}</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="回收单位：">{{entityObj.purchaseUnityName}}</el-form-item>
					</el-col>
					
				</el-row>
				<el-row>
					<el-form-item label="空瓶清单：">
					</el-form-item>
					<el-form-item label="" label-width="0px">
						<el-table :data="entityObj.recoveryOrderItems" border style="width: 800px" show-summary>
							<el-table-column label="空瓶编码" min-width="120">
								<template #default="scope">{{ scope.row.materialCode }}</template>
							</el-table-column>
							<el-table-column label="空瓶名称" min-width="230">
								<template #default="scope">{{ scope.row.materialName }}</template>
							</el-table-column>
							<el-table-column label="规格" min-width="100">
								<template #default="scope">{{ scope.row.materialSpecs }}</template>
							</el-table-column>
							<el-table-column label="单位" min-width="60">
								<template #default="scope">{{ scope.row.unitName }}</template>
							</el-table-column>
							<el-table-column label="门店单价" min-width="100">
								<template #default="scope">
									<el-input v-model="scope.row.storePrice" style="width: 100%"
									></el-input>
								</template>
							</el-table-column>
							<el-table-column label="供应商单价" min-width="100">
								<template #default="scope">
									<el-input v-model="scope.row.supplierPrice" style="width: 100%"
									></el-input>
								</template>
							</el-table-column>						
						</el-table>
					</el-form-item>
				</el-row>
			</el-form>
			<template #footer>
				<div style="text-align: center;">
					<el-button @click="visible = false">关 闭</el-button>
					<el-button v-if="mode != 'Show'" type="primary" @click="submitSave()">确定</el-button>
				</div>
			</template>
		</el-dialog>
		
	</section>
</template>

<script>
	export default {
		data() {
			return {
				mode: '',
				visible: false,
				entityObj: {},
				modalSup: {},
				visibleSup: false,
				backRecoveryCount1: 0,
				backrecoveryCount2: 0,
				materialState: false,
				queryMaterialList:{}
			}
		},
		methods: {
			open(data) {
				this.mode = "Add";
				this.visible = true;
				this.entityObj = data;
				console.log("open",data)
			},
			show(data) {
				this.mode = "Show"
				this.visible = true;
				this.entityObj = data;
				console.log(data)
			},
			async submitSave() {
				this.entityObj.recoveryOrderItems.forEach(p => {
					p.recoveryPrice=p.storePrice,
					p.reSupplierPrice=p.supplierPrice
				});
				try {
					const returnValue = await this.$API.auth.PostProcessApi.post(
						"recovery-order/update-price",
						this.entityObj.recoveryOrderItems
					);
					if (returnValue.status == 200) {
						this.$message.success(returnValue.msg);
						this.$emit("success");
						this.visible = false;
					} else {
						this.$message.error("操作失败:" + returnValue.msg);
					}
				} catch (error) {
					this.loading = false;
					this.$message.error(error.message);
					return false;
				}
			}
		}
	}
</script>

<style scoped>
/deep/ .el-upload--picture-card{
    width: 50px;
    height: 50px;
}
/deep/ .el-upload{
    width: 50px;
    height: 50px;
    line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item{
    width: 50px;
    height: 50px;
    line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item-thumbnail{
    width: 50px;
    height: 50px;
    line-height: 50px;
}
/deep/ .el-table .info-row > td 
{
    background:#e4e7ed;
    user-select: none; /* 禁用文本选择 */
    pointer-events: none; /* 禁用鼠标事件 */


}
</style>
